<script setup lang='ts'>
interface Props {
  si: number
}

defineOptions({ name: 'AppSportsEventsNav' })
const props = defineProps<Props>()

const isLayerOpen = ref(false)
</script>

<template>
  <div class="flex relative w-full">
    <!-- 下拉按钮 -->
    <div class="drop-down-btn" @click="isLayerOpen = !isLayerOpen">
      <BaseIcon name="uni-triangle" />
    </div>
    <!-- 滚动列表 -->
    <div class="w-full overflow-hidden relative">
      <BaseSportsTabScrollMask class="h-[56px]">
        <div class="flex">
          <div v-for="i in 10" :key="i" class="event-item" :class="{ active: i === 1 }">
            <!-- 状态、时间 -->
            <div class="time">
              <BaseIcon name="sports-live" class="text-[16px] mr-[4px]" />
              <BaseIcon name="sports-live-screen2" class="text-[16px] mr-[4px]" />
              <div class="text">62′ 2nd half</div>
            </div>
            <div class="flex">
              <!-- 比分、队名 -->
              <div class="flex flex-col items-center mr-[8px] opacity-50">
                <div class="min-w-[16px] text-center">0</div>
                <div class="min-w-[16px] text-center">4</div>
              </div>
              <div class="flex flex-col whitespace-nowrap">
                <div>摩纳哥体育会 [AI]</div>
                <div>LOSC里尔 [AI]</div>
              </div>
            </div>
          </div>
        </div>
      </BaseSportsTabScrollMask>
    </div>

    <!-- 弹出层 -->
    <div v-show="isLayerOpen" style="top:calc(100% + 8px);" class="w-full z-[10] left-0 absolute max-w-full box-border">
      <AppSportsAllRegionList :si="si" />
    </div>
  </div>
</template>

<style lang='scss' scoped>
.drop-down-btn {
  color: rgba(255, 255, 255, 0.5);
  width: 28.727px;
  cursor: pointer;
  height: 56px;
  display: flex;
  overflow: hidden;
  position: relative;
  background: rgba(58, 65, 66, 0.5);
  transition: all 0.3s;
  align-items: center;
  margin-right: 8px;
  border-radius: 6px;
  flex-direction: column;
  justify-content: center;
}

.event-item {
  height: 56px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-weight: 590;
  line-height: 16px;
  padding: 4px 8px;
  background: rgba(58, 65, 66, 0.50);
  border-radius: 8px;
  margin-right: 8px;
  flex: 0 0 auto;
  cursor: pointer;
  display: flex;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  transition: 0.3s;
  flex-direction: column;

  &:last-of-type {
    margin-right: 0;
  }

  .time {
    display: flex;

    .text {
      font-size: 10px;
      white-space: nowrap;
      letter-spacing: 0.24px;
      vertical-align: middle;
    }
  }

  &.active {
    color: #fff;
    background: #3A4142;

    .time {
      color: rgb(33, 168, 247);
    }
  }

  @media (hover: hover) and (pointer: fine) {
    &:hover {
      color: #fff;
      background: #3A4142;
    }
  }
}

.layer {
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  z-index: 10;
  position: absolute;
  max-width: 100%;
  box-sizing: border-box;

  .content-wrap {
    width: 100%;
    max-width: 100%;
    background: rgb(41, 45, 46);
    box-shadow: rgba(0, 0, 0, 0.16) 0px 5px 16px;
    box-sizing: border-box;
    max-height: 380px;
    overflow: hidden auto;
    border-radius: 12px;
    padding-top: 28px;
    padding-left: 20px;
    padding-right: 16px;
    padding-bottom: 28px;

    &::after {
      left: 0px;
      width: calc(100% - 12px);
      bottom: 0px;
      height: 24px;
      content: "";
      z-index: 2;
      position: absolute;
      background: linear-gradient(to top, rgb(41, 45, 46), rgba(41, 45, 46, 0));
      pointer-events: none;
    }
  }
}
</style>
